/**
 * @PROJECT 
 * @DATE 2018年7月23日 下午3:44:15
 * @AUTHOR LUYU
 */
package com.kool.data.db;

import java.util.ArrayList;
import java.util.List;

import org.bson.Document;

import com.mongodb.MongoClient;
import com.mongodb.MongoClientOptions;
import com.mongodb.MongoClientURI;
import com.mongodb.MongoCredential;
import com.mongodb.ServerAddress;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoDatabase;

/**
 * @DESCRIBE
 * @AUTHOR LUYU
 * @DATE 2018年7月23日 下午3:44:15
 *
 */
public class MongoDBJDBC {
	public static void main(String args[]) {
		try {
            MongoClientURI uri = new MongoClientURI("mongodb://koolrun:koolrun@localhost/?authSource=hisaas_data");
            MongoClient mongoClient = new MongoClient(uri);
            //连接到数据库  
            MongoDatabase mongoDatabase = mongoClient.getDatabase("hisaas_data");  
            System.out.println("Connect to database successfully");  
		      mongoDatabase.createCollection("test1");
		       MongoCollection<Document> collection = mongoDatabase.getCollection("test1");
		       System.out.println("集合 test 选择成功");
		} catch (Exception e) {
			System.err.println(e.getClass().getName() + ": " + e.getMessage());
		}
	}
}
